package com.edwin.websitebe.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.edwin.websitebe.mapper.TopGameMapper;
import com.edwin.websitebe.model.TopGame;
import com.edwin.websitebe.service.TopGameService;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
public class TopGameServiceImpl extends ServiceImpl<TopGameMapper, TopGame> implements TopGameService {


    @Override
    public synchronized TopGame get() {
        TopGame topGame = this.getOne(new QueryWrapper<>());
        if (Objects.nonNull(topGame)) {
            return topGame;
        } else {
            topGame = new TopGame(null, "", "");
            this.save(topGame);
            return topGame;
        }
    }

}